<?php echo $left ?>
<script>
$( document ).ready(function() {
	$.ajaxSetup({
		cache: false
	});
	$( '.sidebar' ).simpleSidebar({
		settings: {
			opener: '#open-sb',
			wrapper: '.wrapper',
			animation: {
				duration:0,
				easing: 'easeOutQuint'
			}
		},
		sidebar: {
			align: 'left',
			width: 214,
			closingLinks: 'a',
		}
	});
});
</script>
	<style type="text/css">
		*{box-sizing: border-box}
		.table tr th{width:16.6%}
		#root label{height:100%;line-height:30px;display:inline-block;width:100%;border-bottom: 1px solid #e9e9e9}
		label a{display: inline-block;width:100%}
		label a i{display: inline-block;width:16.6%;float:left;font-style: normal;line-height:20px;height:100%;padding-top:10px; text-align:center;}
		#root li{line-height:30px;position:relative;}
		#root .two{display:none;padding-left:20px;}
		#root span{position:absolute;top:13px;}
		#root .add{background:url(<?=base_url()?>public/img/tb.gif) -4px -31px no-repeat;}
		#root .ren{background:url(<?=base_url()?>public/img/tb.gif) -4px -7px no-repeat;}
		#root .btn_add{position:absolute;top:13px;display: inline-block; height: 18px; vertical-align: middle; width: 16px; cursor: pointer;}

		#root {
			margin-left:10px;
		}
		#root a{text-decoration: none;color:#333}
		#root li {
			list-style-type:none;
			margin:0;
			position:relative
		}
		#root .two li::before, #root .two li::after {
			content:'';
			left:-20px;
			position:absolute;
			right:auto
		}
		#root .two li::before {
			border-left:1px dotted #999;
			height:100%;
			left:-11px;
			top:-15px;
			width:1px
		}
		#root .two li::after {
			border-top:1px dotted #999;
			height:20px;
			top:21px;
			left:-11px;
			width:15px
		}
		#root .two li.parent_li>label {
			cursor:pointer
		}
		#root .two>ul>li::before, #root .two>ul>li::after {
			border:0
		}
		#root .two li:last-child::before {
			height:35px
		}

		.leftnav h3 .jiantou{right:15px !important;}
	</style>
<div class="clear"></div>
<div  class="w640">
      <div class="yd3 pt50"><span class="ydtxt">公益收益中心</span> - 我的会员</div>
	<input type="hidden" id="dqjb" name="dqjb" value="<?php echo $dqjb; ?>" />
	  <table cellpadding="0" cellspacing="0"  class="altrowstable" id="alternatecolor">
	     <tr>
		    <th>公益账号</th>
            <th>姓名</th>
			<th>推广人数</th>
			<th>级别</th>
			<th>手机号</th>
			<th>状态</th>
	     </tr>
		  <tr>
			  <td colspan="6">
				  <ul id="root">
					  <?php foreach ($member_list as $key => $v):?>
						  <li>
							  <?php if($v['tj_num'] > 0): ?>
								  <span class="add btn_add" acc="<?php echo $v['user_account'] ?>" abb="1" ></span>
							  <?php endif; ?>
							  <label>
								  <a href="javascript:">
									  <i style="width:22%"><?php echo substr_replace($v['user_account'],'***',2,3) ?></i>
									  <i style="width:13%"><?php echo $v['user_name'] ?></i>
									  <i style="width:23%"><?php echo $v['tj_num'] ?></i>
									  <i style="width:12%"><?php echo $v['tlv'] ?></i>
									  <i style="width:18%"><?php echo $v['mobile'] ?></i>
									  <i style="width:12%"><?php if($v['kick_status'] == '1') {echo "已封号";} else {echo "正常";}?></i>
								  </a>
							  </label>
						  </li>
					  <?php endforeach;?>
				  </ul>
			  </td>
		  </tr>
  </table>
</div>
<script type="text/javascript">
function altRows(id){
	if(document.getElementsByTagName){  
		
		var table = document.getElementById(id);  
		var rows = table.getElementsByTagName("tr"); 
		 
		for(i = 0; i < rows.length; i++){          
			if(i % 2 == 0){
				rows[i].className = "evenrowcolor";
			}else{
				rows[i].className = "oddrowcolor";
			}      
		}
	}
}

window.onload=function(){
	altRows('alternatecolor');
}
</script>
<script type="text/javascript" >
var url = '<?php echo site_url('mobile/my_member/ajax_get_member_list') ?>';
var canDown=true;
var time=0;

$('#root').delegate('.btn_add','click', function aa(event) {
	//console.log(this);
	//$(this).removeClass('add');
	if(event.target.nodeName==="SPAN"){
		var time1=new Date().getTime();
		if(time1-time>=300){
			time=time1;
			$_this = $(this);
			$_this.off('click');
			if($_this.hasClass('ren')){
				//console.log(2);
				canDown=true;
				$_this.parent().children('ul').remove('.two');
				$_this.removeClass('ren').addClass('add');
				$_this.on('click',aa);
			}else{
				if($_this.attr('acc')){
					if ($('#dqjb').val() == $_this.attr('abb')) {
						alert("会员只能查看"+$('#dqjb').val()+"代");
						return;
					}
					if ($_this.attr('abb') == '5') {
						alert("会员只能查看5代");
						return;
					} else {
						var abb= parseInt($_this.attr('abb')) + parseInt(1);
					}
					if(canDown){
						canDown=true;
						$.post(url, {'acc':$_this.attr('acc')}, function(d) {
							//console.log(d);
							var html = '';
							html += '<ul class="two">';
							if(d){
								for (var i = 0; i < d.length; i++) {
									html += '<li>';
									if(d[i]['tj_num'] > 0){
										html += '<span class="add btn_add" acc="'+d[i]['user_account']+'" abb="'+abb+'"></span>'
									}
									html += '<label>';
									html += '<a href="javascript:">'
									html += '<i>'+d[i]['user_account'].substr(0, 2)+'***'+d[i]['user_account'].substr(5)+'</i>';
									html += '<i>'+d[i]['user_name']+'</i>';
									html += '<i>'+d[i]['tj_num']+'</i>';
									html += '<i>'+d[i]['tlv']+'</i>';
									html += '<i>无权限</i>';
									if (d[i]["kick_status"] == "1"){
										html += '<i>已封号</i>';
									} else {
										html += '<i>正常</i>';
									}

									//					html += '<i>'+d[i]['mobile']+'</i>';
									html += '</a>';
									html == '</label>';
									html += '</li>';
								}
							}
							html += '</ul>';
							console.log($_this.siblings(".two").length);
							if($_this.siblings(".two").length>=1){
								return;
							}else{
								$($_this.parent()).append(html);
								$_this.removeClass('add');
								$_this.addClass('ren');
								$_this.on('click',aa);
								$('.two').show();
							}
						});
					}
				}
			}
		}
	}
});
$("#alternatecolor").delegate(".ping","click",function(){
	var me=this;
	if($(this).html()>0){
		var id=parseInt($(this).parent().attr("data-id"));
		if($(this).hasClass("close")&&$(this).parent().attr("data-id")<5){
			$.post(url, {'acc':$(this).attr('acc')}, function(d) {
				//console.log(d);\
			//	var d=[{"user_account":"1234564697","user_name":"我是测试名字","tj_num":2,"tlv":"任何","mobile":15016147075}];
				var html = '';
				
				if(d){
					for (var i = 0; i < d.length; i++) {
						html += '<tr data-id='+(id+1)+'>';
					/*	if(d[i]['tj_num'] > 0){
							html += '<span class="add btn_add" acc="'+d[i]['user_account']+'"></span>'
						}*/
						html += '<td>'+d[i]['user_account'].substr(0, 2)+'***'+d[i]['user_account'].substr(5)+'</td>';
						html += '<td>'+d[i]['user_name']+'</td>';
						html += '<td class="ping close" data-name="'+$(me).prev().html()+'">'+d[i]['tj_num']+'</td>';
						html += '<td>'+d[i]['tlv']+'</td>';
						//html += '<td>无权限</i>';
						html += '<td>'+d[i]['mobile']+'</td>';
						html +='<td>正常</td>';
						html += '</tr>';
					}
				}
				$(this).parent().after(html);
				altRows('alternatecolor');
				setColor(checkColor($(this).attr("data-id")));
				$(this).removeClass("close");
			});
		}else{
			var name=$(this).prev().html();
			var id=$(this).parent().attr("data-id");
			$(".ping").each(function(i){
				if($(this).parent().attr("data-id")>id){
					$(this).parent().remove();
				}
			});
			$(this).addClass("close");
		}
	}
});
	
	
/**我的会员层级颜色**/
function checkColor(state){
	if(state==1){
		return "#cce6b1";
	}else if(state==2){
			return "#daf1c0";
	}else if(state==3){
			return "#ecf8c2";
	}else if(state==4){
			return "#f6fad0";
	}else if(state==5){
			return "#fcffe7";
	}
}
//设置层级颜色
function setColor(){
	$("tr").each(function(){
		if($(this).attr("data-id")){
			var color=checkColor($(this).attr("data-id"));
			$(this).css("background-color",color);
		}
	});
}
setColor();
</script>
<?php echo $foot; ?>